package com.edu.exam.entity.examination.paper.technical;

import com.edu.exam.enums.examination.paper.TemplateType;
import com.edu.exam.enums.examination.paper.TemplateStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import jakarta.persistence.*;
import java.time.LocalDateTime;

/**
 * 答题卡模板实体类
 * 所属模块：E-01 考试执行模块
 * 对应数据库表：answer_sheet_template
 *
 * <p>根据E-04-01设备适配子模块数据库设计实现，
 * 存储答题卡模板的定义和配置信息。用于OMR识别的答题卡模板管理。</p>
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class AnswerSheetTemplate {

    /**
     * 模板ID，主键
     */
    @Id
    @Column(name = "template_id", length = 64)
    private String templateId;

    /**
     * 模板名称
     */
    @Column(name = "template_name", length = 128, nullable = false)
    private String templateName;

    /**
     * 考试ID
     */
    @Column(name = "exam_id", length = 64, nullable = false)
    private String examId;

    /**
     * 模板版本
     */
    @Column(name = "template_version", length = 32, nullable = false)
    private String templateVersion;

    /**
     * 模板类型
     */
    @Column(name = "template_type", length = 32, nullable = false)
    private String templateType;

    /**
     * 模板状态
     */
    @Column(name = "template_status", length = 32, nullable = false)
    private String templateStatus;

    /**
     * 考号区域定义
     */
    @Column(name = "exam_id_region", length = 256)
    private String examIdRegion;

    /**
     * OMR区域定义
     */
    @Column(name = "omr_regions", columnDefinition = "TEXT")
    private String omrRegions;

    /**
     * 主观题区域定义
     */
    @Column(name = "subjective_regions", columnDefinition = "TEXT")
    private String subjectiveRegions;

    /**
     * 模板元数据
     */
    @Column(name = "template_metadata", columnDefinition = "TEXT")
    private String templateMetadata;

    /**
     * 创建人ID
     */
    @Column(name = "created_by", length = 64, nullable = false)
    private String createdBy;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 版本号（用于乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Integer version = 0;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

}